import ImageModel from "../../../models/Image";
import config from "../../../config/config";

const imageModel = new ImageModel()

Page({
  data: {
    image: ''
  },
  onLoad: function (options) {
    imageModel.getWxImage().then(data => {
      let image = data.image
      image = config.app_base_url + image
      this.setData({ image })
    })
  },

  downQrcode() {
    wx.downloadFile({
      url: this.data.image,
      success: (res) => {
        if (res.statusCode === 200) {
          wx.saveImageToPhotosAlbum({
            filePath: res.tempFilePath,
            success: () => {
              wx.showToast({
                title: '保存成功',
                success: () => {
                }
              })
            }
          })
        }
      },
      complete: () => {
        this.setData({
          product_qrcode: ''
        })
      }
    })
  }
});
